package com.cloudeasy.post.authorize;

import com.cloudeasy.core.authorize.AuthorizeConfigProvider;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
import org.springframework.stereotype.Component;

/**
 * 用户授权配置提供者
 */
@Component
@Order(Integer.MIN_VALUE)
public class PostAuthorizeConfigProvier implements AuthorizeConfigProvider {
    @Override
    public void config(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry config) {
        config.antMatchers(HttpMethod.GET,
                "/{authorId:\\d+}",
                "/{authorId}/{page}/{size}",
                "/one/{id:\\d+}",

                "/list",
                "/list/{page}/{size}",

                "/reply/one/{id:\\d+}",
                "/reply/{postId}/{page}/{size}",

                "/storey/{replyId}"
        )
                .permitAll();
    }
}
